<template>
  <view>
    <view class="content">
      <!-- 头部 -->
      <view class="head">
        <view class="icon">
          <image src="../imgs/icon/地标.png" />杭州市梦想小镇
        </view>
        <view class="icon">
          <image src="../imgs/icon/消息通知.png" />
        </view>
      </view>
      <view class="container">
        <view class="box">
          <image src="../imgs/icon/搜索.png" class="search" />
          <input type="text" placeholder="永辉超市优惠商品" class="input" />
        </view>
      </view>
    </view>
    <!-- 图片 -->
    <view class="img">
      <image src="../imgs/assets/02.jpg" />
    </view>
    <!-- 列表 -->
    <view class="center">
      <view class="image-row">
        <image src="../imgs/assets/super.png"></image>
        <image src="../imgs/assets/market.png"></image>
        <image src="../imgs/assets/fruits.png"></image>
        <image src="../imgs/assets/flower.png"></image>
        <image src="../imgs/assets/drug.png"></image>
      </view>
      <view class="image-row">
        <image src="../imgs/assets/home.png"></image>
        <image src="../imgs/assets/cake.png"></image>
        <image src="../imgs/assets/sign.png"></image>
        <image src="../imgs/assets/prestige.png"></image>
        <image src="../imgs/assets/red.png"></image>
      </view>
    </view>
    <!-- 推荐店铺 -->
    <view class="shop">
      <view class="shop-top">
        <view>推荐店铺</view>
        <view @click="much()">查看更多</view>
      </view>
      <view class="shop-center">
        <view v-for="(shop, index) in shopList" :key="index" class="shop-item" @click="deletil(shop._id)">
          <image :src="shop.imgUrl" />
          <view class="massage">
            <view>{{shop.name}}</view>
            <view>
              月售: {{shop.sales}}  
              起送: {{shop.expressLimit}}  
              基础运费: {{shop.expressPrice}}
            </view>
            <view style="color: red">{{shop.slogan}}</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      shopList: []
    }
  },
  onLoad() {
    this.shop();
  },

  methods: {
    shop() {
      uni.request({
        url: "http://localhost:3000/data",
        success: (res) => {
          this.shopList = res.data;
        }
      })
    },
    much() {
      uni.navigateTo({
        url: "/pages/near/index"
      })
    },
    deletil(id) {
      uni.navigateTo({
        url: `/pages/deletil/index?id=${id}`
      })
    },
  }
}
</script>

<style>
.content {
  width: 100%;
  height: 200px;
  background-color: rgb(108, 196, 247);
  display: flex;
  flex-direction: column;
  padding: 0 20px;
  box-sizing: border-box;
}

.img image {
  width: 100%;
}

.head {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 100%;
  font-size: 30px;
  font-weight: 500;
  color: white;
}

.icon {
  margin: 15px 0;
}

.head image {
  width: 30px;
  height: 30px;
  margin-top: 30px;
  margin-right: 10px;
}
/* 搜索框 */
.container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 5px;
}

.box {
  display: flex;
  align-items: center;
  background-color: white;
  border-radius: 15px;
  padding: 10px 15px; 
  width: calc(100% - 40px); 
  box-sizing: border-box;
}
.search {
  width: 20px;
  height: 20px;
  margin-right: 10px;
}
.input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
}
.center {
  width: 100%;
  height: 400px;
  background: linear-gradient(to bottom, rgb(108, 196, 247), white);
  display: flex;
  justify-content: space-evenly; /* 水平方向均匀分布 */
  align-items: center; /* 垂直方向居中对齐 */
  flex-wrap: wrap; /* 使图片换行显示 */
}
.image-row {
  display: flex;
  width: 100%;
  justify-content: space-around;
  margin-bottom: 20px; /* 行与行之间的间距 */
}
.image-row image {
  width: 100px; /* 设置图片宽度 */
  height: 100px; /* 设置图片高度 */
}
/* 店铺推荐 */
.shop-top{
  flex-direction: row;
  display: flex;
  justify-content: space-between;
  height: 60px;
  line-height: 60px;
  margin: 0 20px;
  font-size: 25px;
  font-weight: 500;
  border-bottom: 1.5px gray solid;
}
.shop .shop-center{
  height: auto;
}
.shop-item {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  padding: 15px 0;
  height: auto; 
}
/* 店铺图标 */
.shop-item image {
  width: 80px;
  height: 80px;
  margin-right: 20px;
}
.massage{
  flex-direction: column;
  display: flex;
  justify-content: space-between;
}
</style>